package com.liuyz;

import java.io.*;
import java.util.Properties;

@SuppressWarnings({"all"})
public class Properties_ {

    public static void main(String[] args) throws IOException {
        Properties properties = new Properties();
        // properties.put(null, "测试");
        // properties.put("测试", null);
        properties.put("001", "张三");
        properties.put("002", "李四");
        properties.put("003", "王五");
        properties.put("002", "赵六");
        System.out.println(properties);

        System.out.println("--------------------------");
        // new A().read();
        new A().write();
    }

}

class A {
    void read() throws IOException {
        Properties properties2 = new Properties();
        properties2.load(this.getClass().getClassLoader().getResourceAsStream("application.properties"));
        System.out.println(properties2.getProperty("name"));
        System.out.println(properties2.getProperty("password"));
    }

    void write() throws IOException {
        Properties properties = new Properties();
        properties.setProperty("001", "张三");
        properties.setProperty("002", "李四");
        properties.setProperty("003", "王五");
        properties.store(new FileOutputStream("out.properties"), "这是我的输出文件");
    }
}
